package plus;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class CompletableFutureExample {

    // 异步执行无返回值的任务
    public void runTask() {
        CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
            // 异步任务的逻辑
            System.out.println("Running task...");
        });

        // 等待任务执行完成
        future.join();
    }


    public static void main(String[] args) throws InterruptedException, ExecutionException {
        CompletableFutureExample example = new CompletableFutureExample();

        // 测试异步执行无返回值的任务
        example.runTask();
    }
}

